package com.example.xiaomengai.controller;

import com.example.xiaomengai.assistant.Agent;
import com.example.xiaomengai.entity.ChatForm;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

/**
 * 功能
 * 作者：梦天
 * 日期：2025/4/26 14:30
 */
@Tag(name = "聊天模块")
@RestController
@RequestMapping("/xiaomeng")
@Slf4j
@CrossOrigin
public class ChatController {
    @Autowired
    private Agent agent;
    @PostMapping(value = "/chat", produces ="text/stream;charset=utf-8")
    public Flux<String> ChatController(@RequestBody ChatForm chatForm) {
        Flux<String> result = agent.chat(chatForm.getMemoryId(), chatForm.getMessage());
        log.info("result:{}", result);
        return result;
    }

}
